import { UploadApiResult } from './model/uploadModel';
import { defHttp } from '/@/utils/http/axios';
import { UploadFileParams } from '/#/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { UploadBizType } from '/@/enums/uploadEnum';
const globSetting = useGlobSetting();
const apiUrl = globSetting.apiUrl;
import { Api } from '/@/api/url'

/**
 * @description: Upload interface
 */
export function uploadApi(
  params: UploadFileParams, 
  onUploadProgress: (progressEvent: ProgressEvent) => void, 
  isReturnResponse : boolean = false) {
  return defHttp.uploadFile<UploadApiResult>(
    {
      url: Api.uploadUrl,
      onUploadProgress,
    },
    params,
    { isReturnResponse }
  );
}
/**
 * @description: Upload interface
 */
export function uploadImg(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
  console.log("upload image, params: ", params);
  
  return defHttp.uploadFile<UploadApiResult>(
    {
      url: `${Api.uploadUrl}?bizType=${UploadBizType.AVATAR}`,
      onUploadProgress,
    },
    {...params},
    { isReturnResponse: true }
  );
}
